/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-1 = 'agency.aliyuncs.com',
    ap-northeast-2-pop = 'agency.aliyuncs.com',
    ap-south-1 = 'agency.aliyuncs.com',
    ap-southeast-2 = 'agency.aliyuncs.com',
    ap-southeast-3 = 'agency.aliyuncs.com',
    ap-southeast-5 = 'agency.aliyuncs.com',
    cn-beijing = 'agency.aliyuncs.com',
    cn-beijing-finance-1 = 'agency.aliyuncs.com',
    cn-beijing-finance-pop = 'agency.aliyuncs.com',
    cn-beijing-gov-1 = 'agency.aliyuncs.com',
    cn-beijing-nu16-b01 = 'agency.aliyuncs.com',
    cn-chengdu = 'agency.aliyuncs.com',
    cn-edge-1 = 'agency.aliyuncs.com',
    cn-fujian = 'agency.aliyuncs.com',
    cn-haidian-cm12-c01 = 'agency.aliyuncs.com',
    cn-hangzhou = 'agency.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'agency.aliyuncs.com',
    cn-hangzhou-finance = 'agency.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'agency.aliyuncs.com',
    cn-hangzhou-test-306 = 'agency.aliyuncs.com',
    cn-hongkong = 'agency.aliyuncs.com',
    cn-hongkong-finance-pop = 'agency.aliyuncs.com',
    cn-huhehaote = 'agency.aliyuncs.com',
    cn-huhehaote-nebula-1 = 'agency.aliyuncs.com',
    cn-north-2-gov-1 = 'agency.aliyuncs.com',
    cn-qingdao = 'agency.aliyuncs.com',
    cn-qingdao-nebula = 'agency.aliyuncs.com',
    cn-shanghai = 'agency.aliyuncs.com',
    cn-shanghai-et15-b01 = 'agency.aliyuncs.com',
    cn-shanghai-et2-b01 = 'agency.aliyuncs.com',
    cn-shanghai-finance-1 = 'agency.aliyuncs.com',
    cn-shanghai-inner = 'agency.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'agency.aliyuncs.com',
    cn-shenzhen = 'agency.aliyuncs.com',
    cn-shenzhen-finance-1 = 'agency.aliyuncs.com',
    cn-shenzhen-inner = 'agency.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'agency.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'agency.aliyuncs.com',
    cn-wuhan = 'agency.aliyuncs.com',
    cn-wulanchabu = 'agency.aliyuncs.com',
    cn-yushanfang = 'agency.aliyuncs.com',
    cn-zhangbei = 'agency.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'agency.aliyuncs.com',
    cn-zhangjiakou = 'agency.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'agency.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'agency.aliyuncs.com',
    eu-central-1 = 'agency.aliyuncs.com',
    eu-west-1 = 'agency.aliyuncs.com',
    eu-west-1-oxs = 'agency.aliyuncs.com',
    me-east-1 = 'agency.aliyuncs.com',
    rus-west-1-pop = 'agency.aliyuncs.com',
    us-east-1 = 'agency.aliyuncs.com',
    us-west-1 = 'agency.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('agency', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DoDefineRegisterNotificationRequest {
  accountTraceId?: string(name='accountTraceId'),
  emailTemplate?: string(name='emailTemplate'),
  emailTemplateParamsJsonString?: string(name='emailTemplateParamsJsonString'),
  interrupt?: boolean(name='interrupt'),
  invoker?: string(name='invoker'),
  pk?: string(name='pk'),
  smsTemplate?: string(name='smsTemplate'),
  smsTemplateParamsJsonString?: string(name='smsTemplateParamsJsonString'),
}

model DoDefineRegisterNotificationResponseBody = {
  accountTraceId?: string(name='accountTraceId'),
  emailTemplate?: string(name='emailTemplate'),
  emailTemplateParamsJsonString?: string(name='emailTemplateParamsJsonString'),
  interrupt?: boolean(name='interrupt'),
  invoker?: string(name='invoker'),
  pk?: string(name='pk'),
  smsTemplate?: string(name='smsTemplate'),
  smsTemplateParamsJsonString?: string(name='smsTemplateParamsJsonString'),
}

model DoDefineRegisterNotificationResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DoDefineRegisterNotificationResponseBody(name='body'),
}

async function doDefineRegisterNotificationWithOptions(request: DoDefineRegisterNotificationRequest, runtime: Util.RuntimeOptions): DoDefineRegisterNotificationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.accountTraceId)) {
    query['accountTraceId'] = request.accountTraceId;
  }
  if (!Util.isUnset(request.emailTemplate)) {
    query['emailTemplate'] = request.emailTemplate;
  }
  if (!Util.isUnset(request.emailTemplateParamsJsonString)) {
    query['emailTemplateParamsJsonString'] = request.emailTemplateParamsJsonString;
  }
  if (!Util.isUnset(request.interrupt)) {
    query['interrupt'] = request.interrupt;
  }
  if (!Util.isUnset(request.invoker)) {
    query['invoker'] = request.invoker;
  }
  if (!Util.isUnset(request.pk)) {
    query['pk'] = request.pk;
  }
  if (!Util.isUnset(request.smsTemplate)) {
    query['smsTemplate'] = request.smsTemplate;
  }
  if (!Util.isUnset(request.smsTemplateParamsJsonString)) {
    query['smsTemplateParamsJsonString'] = request.smsTemplateParamsJsonString;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DoDefineRegisterNotification',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function doDefineRegisterNotification(request: DoDefineRegisterNotificationRequest): DoDefineRegisterNotificationResponse {
  var runtime = new Util.RuntimeOptions{};
  return doDefineRegisterNotificationWithOptions(request, runtime);
}

model FindAvailableInstancesRequest {
  uid?: long(name='Uid'),
}

model FindAvailableInstancesResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  success?: boolean(name='Success'),
}

model FindAvailableInstancesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: FindAvailableInstancesResponseBody(name='body'),
}

async function findAvailableInstancesWithOptions(request: FindAvailableInstancesRequest, runtime: Util.RuntimeOptions): FindAvailableInstancesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.uid)) {
    query['Uid'] = request.uid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'FindAvailableInstances',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function findAvailableInstances(request: FindAvailableInstancesRequest): FindAvailableInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return findAvailableInstancesWithOptions(request, runtime);
}

model GetMonthDetailLinkRequest {
  month?: string(name='Month'),
  uid?: long(name='Uid'),
}

model GetMonthDetailLinkResponseBody = {
  code?: string(name='Code'),
  data?: {
    billDownloadDTO?: [ 
    {
      billLink?: string(name='BillLink'),
      billTime?: string(name='BillTime'),
      billType?: string(name='BillType'),
      id?: long(name='Id'),
      uid?: long(name='Uid'),
      userType?: string(name='UserType'),
    }
  ](name='BillDownloadDTO')
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GetMonthDetailLinkResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetMonthDetailLinkResponseBody(name='body'),
}

async function getMonthDetailLinkWithOptions(request: GetMonthDetailLinkRequest, runtime: Util.RuntimeOptions): GetMonthDetailLinkResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.month)) {
    query['Month'] = request.month;
  }
  if (!Util.isUnset(request.uid)) {
    query['Uid'] = request.uid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetMonthDetailLink',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getMonthDetailLink(request: GetMonthDetailLinkRequest): GetMonthDetailLinkResponse {
  var runtime = new Util.RuntimeOptions{};
  return getMonthDetailLinkWithOptions(request, runtime);
}

model QueryFxUserDebtsRequest {
  uid?: long(name='Uid'),
}

model QueryFxUserDebtsResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  success?: boolean(name='Success'),
}

model QueryFxUserDebtsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryFxUserDebtsResponseBody(name='body'),
}

async function queryFxUserDebtsWithOptions(request: QueryFxUserDebtsRequest, runtime: Util.RuntimeOptions): QueryFxUserDebtsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.uid)) {
    query['Uid'] = request.uid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryFxUserDebts',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryFxUserDebts(request: QueryFxUserDebtsRequest): QueryFxUserDebtsResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryFxUserDebtsWithOptions(request, runtime);
}

model TransferFxResellerToUserRequest {
  tansferScene?: int32(name='TansferScene'),
  transferUid?: string(name='TransferUid'),
}

model TransferFxResellerToUserResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  success?: boolean(name='Success'),
}

model TransferFxResellerToUserResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TransferFxResellerToUserResponseBody(name='body'),
}

async function transferFxResellerToUserWithOptions(request: TransferFxResellerToUserRequest, runtime: Util.RuntimeOptions): TransferFxResellerToUserResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tansferScene)) {
    query['TansferScene'] = request.tansferScene;
  }
  if (!Util.isUnset(request.transferUid)) {
    query['TransferUid'] = request.transferUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TransferFxResellerToUser',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function transferFxResellerToUser(request: TransferFxResellerToUserRequest): TransferFxResellerToUserResponse {
  var runtime = new Util.RuntimeOptions{};
  return transferFxResellerToUserWithOptions(request, runtime);
}

model TransferFxUserToResellerRequest {
  parentUid?: string(name='ParentUid'),
  quotaAmount?: int32(name='QuotaAmount'),
  shutdownStatus?: int32(name='ShutdownStatus'),
  tansferScene?: int32(name='TansferScene'),
  transferUid?: string(name='TransferUid'),
}

model TransferFxUserToResellerResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  success?: boolean(name='Success'),
}

model TransferFxUserToResellerResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TransferFxUserToResellerResponseBody(name='body'),
}

async function transferFxUserToResellerWithOptions(request: TransferFxUserToResellerRequest, runtime: Util.RuntimeOptions): TransferFxUserToResellerResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.parentUid)) {
    query['ParentUid'] = request.parentUid;
  }
  if (!Util.isUnset(request.quotaAmount)) {
    query['QuotaAmount'] = request.quotaAmount;
  }
  if (!Util.isUnset(request.shutdownStatus)) {
    query['ShutdownStatus'] = request.shutdownStatus;
  }
  if (!Util.isUnset(request.tansferScene)) {
    query['TansferScene'] = request.tansferScene;
  }
  if (!Util.isUnset(request.transferUid)) {
    query['TransferUid'] = request.transferUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TransferFxUserToReseller',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function transferFxUserToReseller(request: TransferFxUserToResellerRequest): TransferFxUserToResellerResponse {
  var runtime = new Util.RuntimeOptions{};
  return transferFxUserToResellerWithOptions(request, runtime);
}

model TransferReplaceResellerRequest {
  operateReason?: string(name='OperateReason'),
  operater?: string(name='Operater'),
  operaterEmpid?: string(name='OperaterEmpid'),
  operaterOrganization?: string(name='OperaterOrganization'),
  parentUid?: string(name='ParentUid'),
  quotaAmount?: int32(name='QuotaAmount'),
  shutdownStatus?: int32(name='ShutdownStatus'),
  tansferScene?: int32(name='TansferScene'),
  transferUid?: string(name='TransferUid'),
}

model TransferReplaceResellerResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  success?: boolean(name='Success'),
}

model TransferReplaceResellerResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TransferReplaceResellerResponseBody(name='body'),
}

async function transferReplaceResellerWithOptions(request: TransferReplaceResellerRequest, runtime: Util.RuntimeOptions): TransferReplaceResellerResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.operateReason)) {
    query['OperateReason'] = request.operateReason;
  }
  if (!Util.isUnset(request.operater)) {
    query['Operater'] = request.operater;
  }
  if (!Util.isUnset(request.operaterEmpid)) {
    query['OperaterEmpid'] = request.operaterEmpid;
  }
  if (!Util.isUnset(request.operaterOrganization)) {
    query['OperaterOrganization'] = request.operaterOrganization;
  }
  if (!Util.isUnset(request.parentUid)) {
    query['ParentUid'] = request.parentUid;
  }
  if (!Util.isUnset(request.quotaAmount)) {
    query['QuotaAmount'] = request.quotaAmount;
  }
  if (!Util.isUnset(request.shutdownStatus)) {
    query['ShutdownStatus'] = request.shutdownStatus;
  }
  if (!Util.isUnset(request.tansferScene)) {
    query['TansferScene'] = request.tansferScene;
  }
  if (!Util.isUnset(request.transferUid)) {
    query['TransferUid'] = request.transferUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TransferReplaceReseller',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function transferReplaceReseller(request: TransferReplaceResellerRequest): TransferReplaceResellerResponse {
  var runtime = new Util.RuntimeOptions{};
  return transferReplaceResellerWithOptions(request, runtime);
}

model DoCheckResourceRequest {
  bid?: string(name='Bid'),
  country?: string(name='Country'),
  gmtWakeup?: string(name='GmtWakeup'),
  hid?: long(name='Hid'),
  interrupt?: boolean(name='Interrupt'),
  invoker?: string(name='Invoker'),
  level?: long(name='Level'),
  message?: string(name='Message'),
  pk?: string(name='Pk'),
  prompt?: string(name='Prompt'),
  success?: boolean(name='Success'),
  taskExtraData?: string(name='TaskExtraData'),
  taskIdentifier?: string(name='TaskIdentifier'),
  url?: string(name='Url'),
}

model DoCheckResourceResponseBody = {
  bid?: string(name='Bid'),
  country?: string(name='Country'),
  gmtWakeup?: string(name='GmtWakeup'),
  hid?: long(name='Hid'),
  interrupt?: boolean(name='Interrupt'),
  invoker?: string(name='Invoker'),
  level?: long(name='Level'),
  message?: string(name='Message'),
  pk?: string(name='Pk'),
  prompt?: string(name='Prompt'),
  success?: boolean(name='Success'),
  taskExtraData?: string(name='TaskExtraData'),
  taskIdentifier?: string(name='TaskIdentifier'),
  url?: string(name='Url'),
}

model DoCheckResourceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DoCheckResourceResponseBody(name='body'),
}

async function doCheckResourceWithOptions(request: DoCheckResourceRequest, runtime: Util.RuntimeOptions): DoCheckResourceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.bid)) {
    query['Bid'] = request.bid;
  }
  if (!Util.isUnset(request.country)) {
    query['Country'] = request.country;
  }
  if (!Util.isUnset(request.gmtWakeup)) {
    query['GmtWakeup'] = request.gmtWakeup;
  }
  if (!Util.isUnset(request.hid)) {
    query['Hid'] = request.hid;
  }
  if (!Util.isUnset(request.interrupt)) {
    query['Interrupt'] = request.interrupt;
  }
  if (!Util.isUnset(request.invoker)) {
    query['Invoker'] = request.invoker;
  }
  if (!Util.isUnset(request.level)) {
    query['Level'] = request.level;
  }
  if (!Util.isUnset(request.message)) {
    query['Message'] = request.message;
  }
  if (!Util.isUnset(request.pk)) {
    query['Pk'] = request.pk;
  }
  if (!Util.isUnset(request.prompt)) {
    query['Prompt'] = request.prompt;
  }
  if (!Util.isUnset(request.success)) {
    query['Success'] = request.success;
  }
  if (!Util.isUnset(request.taskExtraData)) {
    query['TaskExtraData'] = request.taskExtraData;
  }
  if (!Util.isUnset(request.taskIdentifier)) {
    query['TaskIdentifier'] = request.taskIdentifier;
  }
  if (!Util.isUnset(request.url)) {
    query['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'doCheckResource',
    version = '2017-10-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function doCheckResource(request: DoCheckResourceRequest): DoCheckResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  return doCheckResourceWithOptions(request, runtime);
}

